/**
 @file ctc_ipfix_cli.h

 @author  Copyright (C) 2013 Centec Networks Inc.  All rights reserved.

 @date 2013-10-24

 @version v3.0

 This file contains port cli
*/
#ifndef _CTC_CLI_IPFIX_H
#define _CTC_CLI_IPFIX_H

#include "sal.h"
#include "ctc_cli.h"

/**
 @brief  Initialize sdk IPFIX module CLIs

 @param[in/out]   cli_tree     CLI tree

 @return CTC_E_XXX

*/

#ifdef __cplusplus
extern "C" {
#endif

#define CTC_CLI_IPFIX_L4_TYPE_DESC \
"0:None, 1:TCP, 2:UDP, 3:GRE, 4:IPINIP, 5:V6INIP, 6:ICMP, 7:IGMP, 8:SCTP"

#define CTC_CLI_KEY_PORT_STR_DESC \
CTC_CLI_GPORT_DESC,\
CTC_CLI_GPORT_ID_DESC, \
"Logic port",\
"logic port value",\
"Metadata",\
"Metadata value"

#define CTC_CLI_IPFIX_KEY_L2_STR_DESC  \
CTC_CLI_MACDA_DESC,\
CTC_CLI_MAC_FORMAT,\
CTC_CLI_MACSA_DESC,\
CTC_CLI_MAC_FORMAT,\
CTC_CLI_ETHTYPE_DESC,\
"Ether Type value",\
"Cvlan",\
"<0~4k-1>",\
"Cvlan prio",\
"Cvlan prio value",\
"Cvlan cfi",\
"Cvlan cfi value",\
"Svlan",\
"<0~4k-1>",\
"Svlan prio",\
"Svlan prio value",\
"Svlan cfi",\
"Svlan cfi value"

#define CTC_CLI_IPFIX_KEY_L3_STR_DESC  \
"Ip-sa",  \
CTC_CLI_IPV4_FORMAT, \
"Mask-len",  \
"Mask len value<1-32>", \
"Ip-da",  \
CTC_CLI_IPV4_FORMAT,  \
"Mask-len",  \
"Mask len value<0-31>",  \
"Dscp",  \
"Dscp value"

#define CTC_CLI_IPFIX_KEY_L4_STR_DESC \
"L4 Type", \
CTC_CLI_IPFIX_L4_TYPE_DESC, \
"L4-src-port",\
"Scr Port value",\
"L4-dst-port",\
"Dst Port value",\
"ICMP-type ",\
"Type value",\
"ICMP-code",\
"Code value",\
"IGMP-type",\
"TYPE value",\
"TCP flags",\
"TCP flags value",\
"GRE key",\
"GRE key value",\
"Vni",\
"Vni value",\
"L4 sub type",\
"0:None,1:BFD,2:UDPPTP,3:WLAN,4:NTP,5:VXLAN",\
"Aware tunnel info",\
"0:Disable, 1:Enable"

#define CTC_CLI_IPFIX_KEY_CID_STR_DESC \
"Source category id",\
"CID value",\
"Dest category id",\
"CID value"

#define CTC_CLI_IPFIX_DEST_STR_DESC  \
"L2 Mcast dest",\
"L3 Mcast dest",\
"Brocast dest",\
"Aps dest",\
"ECMP dest",\
"Linkagg dest"


#define CTC_CLI_IPFIX_KEY_MPLS_STR_DESC \
"Label-num",\
"Num value",\
"MPLS0-label",\
"Labelvalue",\
"MPLS0-s",\
"Sbit value",\
"MPLS0-exp",\
"Exp value",\
"MPLS0-ttl",\
"TTL value",\
"MPLS1-label",\
"Labelvalue",\
"MPLS1-s",\
"Sbit value",\
"MPLS1-exp",\
"Exp value",\
"MPLS1-ttl",\
"TTL value",\
"MPLS2-label",\
"Labelvalue",\
"MPLS2-s",\
"Sbit value",\
"MPLS2-exp",\
"Exp value",\
"MPLS2-ttl",\
"TTL value"


#define CTC_CLI_IPFIX_KEY_UDF_STR "udf-id VALUE |udf-valid VALUE |udf-data VALUE"

#define CTC_CLI_IPFIX_KEY_UDF_STR_DESC \
    "UDF id",\
    "UDF id Value",\
    "UDF valid",\
    "UDF valid Value",\
    "UDF data",\
    "UDF data Value"
#define CTC_CLI_IPFIX_XKEY_STR "ip-ttl IP-TTL |discard DISCARD discard-type DISCARD-TYPE|priority PRI |src-port SRC-PORT"
#define CTC_CLI_IPFIX_KEY_PORT_STR "(gport GPORT |logic-port LPORT |metadata DATA)"
#define CTC_CLI_IPFIX_KEY_L2_STR "mac-da MACDA| mac-sa MACSA|eth-type ETHER| cvlan CVLAN |cvlan-prio PRIO| cvlan-cfi CFI| svlan SVLAN |svlan-prio PRIO|svlan-cfi CFI "
#define CTC_CLI_IPFIX_KEY_L3_STR "ip-sa IPSA mask-len LEN| ip-da IPDA mask-len LEN |dscp DSCP"
#define CTC_CLI_IPFIX_KEY_L4_STR \
"l4-type L4_TYPE |l4-src-port L4SRCPORT| l4-dst-port L4DSTPORT|icmp-type TYPE| icmp-code CODE |igmp-type TYPE|tcp-flags TCP_FLAGS| gre-key GREKEY|vni VNI |l4-sub-type L4_SUB_TYPE |aware-tunnel-info-en VALUE"
#define CTC_CLI_IPFIX_KEY_CID_STR "src-cid CID|dst-cid CID"

#define CTC_CLI_IPFIX_KEY_IPV4_L4_STR \
"l4-type L4_TYPE |ip-protocol PROTOCOL |l4-src-port L4SRCPORT| l4-dst-port L4DSTPORT|icmp-type TYPE| icmp-code CODE |igmp-type TYPE|tcp-flags TCP_FLAGS| ip-frag IP_FRAG |ip-identification IDNTIFICATION|ip-pkt-len PKT_LEN|"\
"ttl TTL| ecn ECN|gre-key GREKEY|vni VNI|l4-sub-type L4_SUB_TYPE | aware-tunnel-info-en VALUE"

#define CTC_CLI_IPFIX_XKEY_STR_DESC \
"Ip-ttl",\
"Ip-ttl value",\
"Discard",\
"Discard value",\
"Discard-type",\
"Discard type value",\
"priority",\
"priority value",\
"Src-gport",\
"Src-gport value"


#define CTC_CLI_IPFIX_KEY_IPV4_L4_STR_DESC \
"L4 type", \
"L4 type value", \
"Ip Protocol", \
"Protocol value", \
"L4-src-port",\
"Src Port value",\
"L4-dst-port",\
"Dst Port value",\
"ICMP-type ",\
"Type value",\
"ICMP-code",\
"Code value",\
"IGMP-type",\
"TYPE value",\
"TCP-flags",\
"TCP FLAGS value",\
"IP-frag",\
"FRAG value",\
"IP-identification",\
"IDENTIFICATION",\
"IP packet length",\
"Packet length value",\
"TTL",\
"TTL value",\
"Ecn",\
"Ecn value",\
"GRE key",\
"GRE Key value",\
"Vni",\
"Vni value",\
"L4 Sub Type",\
"0:None,1:BFD,2:UDPPTP,3:WLAN,4:NTP,5:VXLAN",\
"Aware tunnel info",\
"0:Disable, 1:Enable"
 /*#define CTC_CLI_IPFIX_KEY_IPV4_STR "("CTC_CLI_IPFIX_KEY_L3_STR"|" CTC_CLI_IPFIX_KEY_L4_STR ")"*/

#define CTC_CLI_IPFIX_KEY_MPLS_STR \
    "label-num NUM| \
     mpls0-label LABEL| mpls0-s SBIT| mpls0-exp EXP| mpls0-ttl TTL| \
     mpls1-label LABEL| mpls1-s SBIT| mpls1-exp EXP| mpls1-ttl TTL| \
     mpls2-label LABEL| mpls2-s SBIT| mpls2-exp EXP| mpls2-ttl TTL"

#define CTC_CLI_IPFIX_L2_L3_KEY_STR \
    "{profile-id PROFILE_ID |" CTC_CLI_IPFIX_KEY_PORT_STR "|" CTC_CLI_IPFIX_KEY_L2_STR "|fid FID|" \
    CTC_CLI_IPFIX_KEY_L3_STR "|ip-protocol PROTOCOL|ip-identification IDENTIFICATION|ip-frag IP_FRAG_VALUE|ttl TTL|ecn ECN|vrfid VRFID|wlan-radio-id ID| wlan-radio-mac MAC |wlan-is-ctl-pkt|"CTC_CLI_IPFIX_KEY_L4_STR"|"\
    CTC_CLI_IPFIX_KEY_MPLS_STR "|arp-op-code OP_CODE|arp-sender-mac SENDER_MAC |arp-target-mac TARGET_MAC| arp-sender-ip SENDER_IP| arp-target-ip TARGET_IP"

#define CTC_CLI_IPFIX_L2_L3_KEY_STR_DESC \
"Config profile id",\
"Profile id",\
CTC_CLI_KEY_PORT_STR_DESC,\
CTC_CLI_IPFIX_KEY_L2_STR_DESC,\
"FID",\
"FID value",\
CTC_CLI_IPFIX_KEY_L3_STR_DESC,\
"IP Protocol",\
"Protocol value",\
"IP-identification",\
"IDENTIFICATION",\
"IP frag",\
"IP_FRAG_VALUE",\
"TTL",\
"TTL value",\
"Ecn",\
"Ecn value",\
"Vrfid",\
"Vrfid value",\
"Radio-id",\
"ID value",\
"Radio mac",\
CTC_CLI_MAC_FORMAT,\
"Is wlan control packet",\
CTC_CLI_IPFIX_KEY_L4_STR_DESC,\
CTC_CLI_IPFIX_KEY_MPLS_STR_DESC,\
"Config arp code",\
"Arp code value",\
"Arp mac sa_value",\
"Arp mac sa in HHHH.HHHH.HHHH format",\
"Arp mac da_value",\
"Arp mac Da in HHHH.HHHH.HHHH format",\
"Arp senderip sa",  \
"Arp address in A.B.C.D format",\
"Arp targetip da",\
"Arp address in A.B.C.D format"


#define CTC_CLI_IPFIX_EXPORT_REASON_STR \
"expired                 | \
tcp-close               | \
pktcnt-overflow         | \
bytecnt-overflow        | \
ts-overflow             | \
hash-conflict           | \
new-flow                | \
dest-change             | \
jitter-overflow         | \
latency-overflow        | \
ttl-change              | \
drop-pktcnt-overflow    | \
drop-reason-change      | \
tc-mark                 | \
dump-entry              | \
burst-event             | \
latency-event           | \
disable"

#define CTC_CLI_IPFIX_EXPORT_REASON_DESC \
"Expired",\
"Tcp Close",\
"PktCnt Overflow",\
"ByteCnt Overflow",\
"Ts Overflow",\
"Hash Conflict",\
"New Flow",\
"Dest Change",\
"Jitter Overflow",\
"Latency Overflow",\
"TTL Change",\
"Drop PktCnt Overflow",\
"Drop Reason Change",\
"Tc Mark",\
"Flush Timer",\
"Burst Event",\
"Latency Event",\
"Disable all"

#define CTC_CLI_IPFIX_DROP_STR \
"none            | \
lpbk-err         | \
parser-err       | \
excp             | \
transmit-dis     | \
receive-dis      | \
fwd-err          | \
vlan-filter      | \
ip-chk           | \
stp-chk          | \
policing         | \
security-chk     | \
port-mac-chk     | \
isolate-chk      | \
pkt-err          | \
hw-err           | \
stk-chk          | \
bpe-port-err     | \
ip-src-guard     | \
lag-empty        | \
aps              | \
scl-deny         | \
acl-deny         | \
ptp              | \
oam              | \
dot1ae           | \
mimicry          | \
vpls             | \
mirror           | \
trill            | \
bfd              | \
pon              | \
arp-or-dhcp-err  | \
arp-miss         | \
vxlan-chk        | \
tunnel-chk       | \
icmp-err         | \
ttl-chk          | \
sd-chk           | \
mpls-chk         | \
mtu-chk          | \
pld-op-err       | \
latency          | \
edit-err         | \
chksum-err       | \
traffic-manager  | \
net-tx           | \
net-rx           | \
buffer-store     | \
queue            "

#define CTC_CLI_IPFIX_DROP_DESC \
"None drop",\
"Loopback error",\
"Parser error",\
"Exception config",\
"Transit disable",\
"Receive disable",\
"Destination check fail",\
"Vlan filtering",\
"Ip address or packet check fail",\
"Stp check fail",\
"Exceed policer threshold",\
"Security check fail",\
"Port mac check fail",\
"Port isolate check fail",\
"Packet check error",\
"Hardware error",\
"Stacking check fail",\
"BPE port configure error",\
"Ip source guard check fail",\
"Linkagg group no member",\
"APS",\
"Scl deny",\
"Acl deny",\
"Ptp packet or config error",\
"Oam packet or config error",\
"Dot1ae packet or config error",\
"Mimicry error",\
"Vpls packet or config error",\
"Mirror config error",\
"Trill packet or config error",\
"Bfd packet or config error",\
"PON error",\
"ARP or DHCP packet check fail",\
"Arp miss",\
"Vxlan check fail",\
"Tunnel check fail",\
"Icmp packet or congfig error",\
"TTL check fail",\
"Signal degradation",\
"Mpls check fail",\
"Mtu check fail",\
"Packet payload operation error",\
"Latency check fail",\
"Next hop edit error",\
"Checksum error",\
"Trafic manager check fail",\
"Nettx check fail",\
"Netrx check fail",\
"Buffer-store",\
"Queue drop"

#define CTC_CLI_IPFIX_KEY_ARG_CHECK(arg_cnt,arg_num,p_field) \
        arg_cnt++; \
        if (p_field && arg_cnt < arg_num) p_field++;\
        if(arg_cnt > arg_num) ret = CTC_E_INTR_INVALID_PARAM;

#define CTC_CLI_IPFIX_XKEY_FIELD_HASH_SET(p_field, arg) \
do{\
    index = CTC_CLI_GET_ARGC_INDEX("ip-ttl");\
    if (0xFF != index) \
    {\
        p_field->type =    CTC_FIELD_KEY_IP_TTL;\
        CTC_CLI_GET_UINT32("ip-ttl", p_field->data, argv[index + 1]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("discard");\
    if (0xFF != index) \
    {\
        p_field->type =    CTC_FIELD_KEY_DISCARD;\
        CTC_CLI_GET_UINT32("discard", p_field->data, argv[index + 1]);\
        CTC_CLI_GET_UINT32("discard-type", p_field->mask, argv[index + 3])\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("priority");\
    if (0xFF != index) \
    {\
        p_field->type =    CTC_FIELD_KEY_PRIORITY;\
        CTC_CLI_GET_UINT32("priority", p_field->data, argv[index + 1]);\
        arg;\
    }\
    index = CTC_CLI_GET_ARGC_INDEX("src-port");\
    if (0xFF != index) \
    {\
        p_field->type =    CTC_FIELD_KEY_SRC_GPORT;\
        CTC_CLI_GET_UINT32("src-port", p_field->data, argv[index + 1]);\
        arg;\
    }\
}while(0);

extern int32
ctc_ipfix_cli_init(void);

#ifdef __cplusplus
}
#endif

#endif
